/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.gwsistemas.buonny.servico;

import br.com.gwsistemas.buonny.entidade.IElemento;
import br.com.gwsistemas.buonny.util.objetos.TipoMensagem;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;

/**
 *
 * @author Olimpio
 */
public class MensagemServiceFactory {
        public static MensagemService getService(TipoMensagem tipo,  IElemento elemento, HashMap<String, String> caracteresTrataveis) {

        MensagemService servico = null;
        try {
            Class classe = Class.forName("br.com.gwsistemas.buonny.servico." + tipo.toString() + "Service");
            Constructor construtor = classe.getConstructor(TipoMensagem.class, IElemento.class, HashMap.class);
            servico = (MensagemService) construtor.newInstance(tipo,elemento, caracteresTrataveis);
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return servico;
    }
}
